/*     */ package com.chw.admin.sysparam;
/*     */ 
/*     */ import com.chw.common.ServiceData;
/*     */ import com.chw.common.ServiceData.RetCode;
/*     */ import com.chw.utils.CommonFieldsUtil;
/*     */ import com.chw.utils.UUIDUtil;
/*     */ import com.github.pagehelper.PageInfo;
/*     */ import com.google.gson.Gson;
/*     */ import java.util.List;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ import org.springframework.web.bind.annotation.ResponseBody;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/sysParams"})
/*     */ public class SysParamsController
/*     */ {
/*  26 */   private static final Logger log = Logger.getLogger(SysParamsController.class);
/*     */ 
/*     */   @Autowired
/*  27 */   private ISysParamsService sysParamsService = null;
/*     */ 
/*     */   public void setSysParamsService(ISysParamsService sysParamsService)
/*     */   {
/*  31 */     this.sysParamsService = sysParamsService;
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"/getSysParams.do"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}, consumes={"*/*"}, produces={"application/json"})
/*     */   @ResponseBody
/*     */   public ServiceData get(HttpServletRequest request, String typeCode)
/*     */     throws Exception
/*     */   {
/*  41 */     ServiceData ret = new ServiceData();
/*     */ 
/*  43 */     List l = this.sysParamsService.selectByCode(typeCode);
/*  44 */     Gson gson = new Gson();
/*  45 */     String json = gson.toJson(l);
/*  46 */     ret.setCode(request, ServiceData.RetCode.Success);
/*  47 */     ret.setBo(json);
/*  48 */     return ret;
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"/getSysParamsById.do"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}, consumes={"*/*"}, produces={"application/json"})
/*     */   @ResponseBody
/*     */   public ServiceData getParam(HttpServletRequest request, String id)
/*     */     throws Exception
/*     */   {
/*  59 */     ServiceData ret = new ServiceData();
/*  60 */     SysParams l = this.sysParamsService.selectById(id);
/*  61 */     Gson gson = new Gson();
/*  62 */     String json = gson.toJson(l);
/*  63 */     ret.setCode(request, ServiceData.RetCode.Success);
/*  64 */     ret.setBo(json);
/*  65 */     return ret;
/*     */   }
/*     */   @RequestMapping(value={"/updateSysParams.do"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}, consumes={"*/*"}, produces={"application/json"})
/*     */   @ResponseBody
/*     */   public ServiceData updateSysParams(HttpServletRequest request, String param) throws Exception {
/*  72 */     ServiceData ret = new ServiceData();
/*  73 */     Gson gson = new Gson();
/*  74 */     SysParams sysParams = (SysParams)gson.fromJson(param, SysParams.class);
/*  75 */     CommonFieldsUtil.setUpdateValue(sysParams);
/*     */ 
/*  77 */     int i = this.sysParamsService.updateSysParams(sysParams);
/*  78 */     ret.setCode(request, ServiceData.RetCode.Success);
/*  79 */     ret.setBo("");
/*  80 */     return ret;
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"/deleteSysParamById.do"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}, consumes={"*/*"}, produces={"application/json"})
/*     */   @ResponseBody
/*     */   public ServiceData deleteRaProductById(HttpServletRequest request, String id)
/*     */     throws Exception
/*     */   {
/*  90 */     ServiceData ret = new ServiceData();
/*  91 */     int i = this.sysParamsService.deleteById(id);
/*  92 */     ret.setCode(request, ServiceData.RetCode.Success);
/*  93 */     ret.setBo(Integer.valueOf(i));
/*  94 */     return ret;
/*     */   }
/*     */   @RequestMapping(value={"/addEntitySysParam.do"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}, consumes={"*/*"}, produces={"application/json"})
/*     */   @ResponseBody
/*     */   public ServiceData addEntityRaProduct(HttpServletRequest request, String param) throws Exception {
/* 101 */     ServiceData ret = new ServiceData();
/* 102 */     Gson gson = new Gson();
/* 103 */     SysParams sysParams = (SysParams)gson.fromJson(param, SysParams.class);
/* 104 */     sysParams.setId(UUIDUtil.getUUID());
/* 105 */     CommonFieldsUtil.setCreateValue(sysParams);
/*     */ 
/* 107 */     int i = this.sysParamsService.addSysParams(sysParams);
/* 108 */     ret.setCode(request, ServiceData.RetCode.Success);
/* 109 */     ret.setBo(Integer.valueOf(i));
/* 110 */     return ret;
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"/getNextSysParamsById.do"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}, consumes={"*/*"}, produces={"application/json"})
/*     */   @ResponseBody
/*     */   public ServiceData getNextSysParamsById(HttpServletRequest request, SysParams sysParams, Integer currentPage, Integer pageSize)
/*     */     throws Exception
/*     */   {
/* 120 */     ServiceData ret = new ServiceData();
/* 121 */     sysParams = this.sysParamsService.selectById(sysParams.getId());
/* 122 */     PageInfo l = this.sysParamsService.selectByCodes(sysParams, currentPage, pageSize);
/* 123 */     ret.setCode(request, ServiceData.RetCode.Success);
/* 124 */     ret.setBo(l);
/* 125 */     return ret;
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"/getSysParamsList.do"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}, consumes={"*/*"}, produces={"application/json"})
/*     */   @ResponseBody
/*     */   public ServiceData getSysParamsList(HttpServletRequest request, SysParams sysParams, Integer currentPage, Integer pageSize) throws Exception
/*     */   {
/* 134 */     ServiceData ret = new ServiceData();
/*     */ 
/* 136 */     PageInfo params = this.sysParamsService.pageParams(sysParams, currentPage, pageSize);
/* 137 */     ret.setCode(request, ServiceData.RetCode.Success);
/* 138 */     ret.setBo(params);
/* 139 */     return ret;
/*     */   }
/*     */ }

/* Location:           E:\chenya\haha\admin java\sysparam\
 * Qualified Name:     com.chw.admin.sysparam.SysParamsController
 * JD-Core Version:    0.6.0
 */